package com.sh.apithirdpay.utils;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class OrderPaySuccessMqUtils {

    @Resource // 自动注入 JmsTemplate 实例
    private JmsTemplate jmsTemplate;

    @Value(value = "${sendOrderPayToJMS}") // 从配置文件中注入队列名称
    private String queueName;
    public void sendOrderPaySuccess(String outTradeNo) {
        if (outTradeNo==null){
            throw new RuntimeException("订单号不能为空");
        }
        jmsTemplate.convertAndSend(queueName, outTradeNo);
        log.info("发送消息到消息队列:::"+ outTradeNo);
    }
}
